# _*_ coding:utf-8 _*_
from flask import Flask, render_template
import psycopg2
import sys

# 从数据库取数据
conn = psycopg2.connect(database='futures', user='postgres', password='234', host='127.0.0.1', port='5432')
#print "成功连接"
#字符转换
reload(sys)
sys.setdefaultencoding('utf-8')
app = Flask(__name__)
@app.route('/')
def v_index():
    cur = conn.cursor()
    cur.execute("SELECT * FROM public.crud_db;")
    conn.commit()
    rows = cur.fetchall()
    cur.close()

    data = list()
    for i in rows:
        data.append({'id': i[0], 'name': i[1], 'phone': i[2], 'qq': i[3], 'email': i[4], 'adress': i[5], 'beizhu': i[6]})
    return render_template("table.html", user=data)
app.run(host='127.0.0.1', port=8080, debug=True )

def v_add():
    return 0

def v_del():
    return 0
